/**
 * 详情对话框
 */
var ToolExpressScanInfoDlg = {
    data: {
        state: "",
        waveId: "",
        orderNumber: "",
        userId: "",
        userName: "",
        v1: "",
        v2: ""
    }
};

/**
 * 详情对话框
 */
var ToolTaskArrangeInfoDlg = {
    data: {
        groupNumber: "",
        groupUsers: ""
    }
};
var submit = 0
layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/toolWork/addWork?ids="+Feng.getUrlParam("ids")+"&waveId="+Feng.getUrlParam("waveId"), function (data) {
    		if (data.success) {
            	Feng.success("更新成功!");
				parent.submit = 1
		    	var Index = parent.layer.getFrameIndex(window.name);
		        parent.layer.close(Index);
			} else {
                Feng.error("提交失败！"+data.message);
			}
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    //点击选择小组
    $('#selectArrange').click(function () {
		var positionNumber = $("input[name='arrangeNumber']:checked").val();
		submit = 0
        layer.open({
            type: 2,
            title: '选择小组',
            area: ['650px', '350px'],
            content: Feng.ctxPath + '/toolWave/toselectArrange2?waveId='+Feng.getUrlParam("waveId")+"&groupNumber="+positionNumber,
            end: function () {
            	if(submit == 1){
                	$("#userName").val(ToolTaskArrangeInfoDlg.data.groupUsers);//小组人员
            	}
            }
        });
    });

    //返回按钮
    $("#backupPage").click(function () {
    	var Index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(Index);
    });

});